package cn.wen.eeayjoke.ui;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.wen.zxing.OnScanListener;
import com.wen.zxing.ZxingUtil;

import butterknife.BindView;
import cn.wen.core.titlebar.DefTitleBar;
import cn.wen.core.ui.AppActivity;
import cn.wen.eeayjoke.R;

/**
 * 二维码测试页面--》》是我用过扫描最快的了
 */
public class ZxingTestActivity extends AppActivity {


    @BindView(R.id.iv_result)
    ImageView mIvResult;

    @Override
    public Object getContentLayout() {
        return R.layout.activity_zxing;
    }

    /**
     * 打开扫描
     */
    public void scan(View view) {
        ZxingUtil.scan(this, new OnScanListener() {
            @Override
            public void onScanSucceed(String result, Bitmap bitmap) {
                Toast.makeText(getAppActivity(), "" + result, Toast.LENGTH_SHORT).show();
                if (bitmap != null) {
                    mIvResult.setImageBitmap(bitmap);
                }
            }
        });
    }


    @Override
    protected void initTitle(DefTitleBar titleBar) {
        titleBar.setTitle("扫描测试");
    }


}
